<?php
  print HTML::style('css/menu.css');
  print HTML::style('css/general.css');
  print HTML::style('css/bootstrap.css');
  print HTML::style('css/login.css');
  
  $facebook = InitFacebookObject();
  $user = InitFacebookUser();

  if ($user) {
    $logoutUrl = URL::to_route('logout');
  } 
  else {
    $params =  array('scope' => "email,publish_stream");
    $loginUrl = $facebook->getLoginUrl($params);
  }

  PrintBeginContent();
?>
<div id="header" class="game-page">
<?php PrintTopMenu(); ?>
  <div class="clear"></div>
</div>

<div class="clear"></div>

<div id="content">
  <h1>Create your acount using Facebook?</h1>
  <h2>Login now by clicking this button:</h2>
  <?php 
  
  
  if ($user)
  {  
    $user_profile = GetFacebookUserProfile();
    RegisterFacebookUser($user_profile);
    print '<span>You are already logged in.'
    . HTML::link('#', 'Logout', array('id' => 'fbConnectLogin', 'class' => 'fb', 'onclick' => 'window.open("' . $logoutUrl . '", "_parent")')) . '?'
    . '</span>';
  }
  else { ?>
  <div>
    <a id="fbConnectLogin" class="fb" href="javascript: void(0)"  onclick="window.open('<?php print $loginUrl; ?>', '_parent')">
      <img src="../img/facebook-connect.gif" alt="">
    </a>
  </div>
<?php } ?>

  <h2>Or, login with your e-mail:</h2>

<?php RenderSignUpForm(); ?>
</div>
<div class="clear"></div>

<?php
  PrintFooterPage(); 
  PrintEndContent();
?>
